{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "滴滴滴\n",
      "104\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3,1,5,2,2,2]\n",
    "# b = (1,2,3)\n",
    "# a.count(2)\n",
    "# a.extend([7,8,6])\n",
    "\n",
    "# 字符串前面+u ，UTF-8 编码\n",
    "print(u\"滴滴滴\")\n",
    "\n",
    "# 占用内存大小\n",
    "print(a.__sizeof__())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是捕获的异常--> 该值不存在！\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    a = [1,1,2,3,4,4,5]\n",
    "    print(a[10])\n",
    "except IndexError:\n",
    "    print(\"这是捕获的异常--> 该值不存在！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 汉诺塔问题\n",
    "def hannoi(n,start,helper,stop):\n",
    "    if n == 1:\n",
    "        print(start + \"--->\" + stop)\n",
    "    else:\n",
    "        hannoi(n-1,start,stop,helper)\n",
    "        hannoi(1,start,helper,stop)\n",
    "        hannoi(n-1,helper,start,stop)\n",
    "\n",
    "hannoi(3,\"A\",\"B\",\"C\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 4, 16, 36, 64, 100]\n",
      "{'A': 0, 'B': 0, 'C': 0}\n"
     ]
    }
   ],
   "source": [
    "# 列表推导式、字典推导式\n",
    "list_a = [ i*i for i in range(11) if i%2==0 ]\n",
    "print(list_a)\n",
    "\n",
    "dict_b = { k:0 for k in {\"A\":1,\"B\":2,\"C\":3} }\n",
    "print(dict_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
  },
  "kernelspec": {
   "display_name": "Python 3.8.2 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
